<template>
  <div class="search">
    <f-form ref="form" :action="api.goods" :form-key="this.formItem.goodsId" >
      <f-form-item label="商品名称"  name="goodsName" dataType="${formField.dataType}"   :value="formItem.goodsName" />
      <f-form-item label="商品价格"  name="goodsPrice" dataType="${formField.dataType}"   :value="formItem.goodsPrice" />
      <f-form-item label="会员价格"  name="vipPrice" dataType="${formField.dataType}"   :value="formItem.vipPrice" />
      <f-form-item label="代理商价格"  name="agentPrice" dataType="${formField.dataType}"   :value="formItem.agentPrice" />
      <f-form-item label="商品图片（轮播图 ）"  name="goodsImg" dataType="${formField.dataType}"   :value="formItem.goodsImg" />
      <f-form-item label="详情图"  name="detailsImg" dataType="${formField.dataType}"   :value="formItem.detailsImg" />
      <f-form-item label="商品类型Id"  name="categoryId" dataType="${formField.dataType}"   :value="formItem.categoryId" />
      <f-form-item label=""  name="isIntegral" dataType="number"   :value="formItem.isIntegral" />
      <f-form-item label="所需积分值"  name="integralValue" dataType="number"   :value="formItem.integralValue" />
      <f-form-item label="商品描述"  name="goodsDesc" dataType="${formField.dataType}"   :value="formItem.goodsDesc" />
      <f-form-item label="库存"  name="inventory" dataType="number"   :value="formItem.inventory" />
      <f-form-item label="销量"  name="sales" dataType="number"   :value="formItem.sales" />
      <f-form-item label="真实销量"  name="realSales" dataType="number"   :value="formItem.realSales" />
      <f-form-item label="封面图"  name="coverImg" dataType="${formField.dataType}"   :value="formItem.coverImg" />
      <f-form-item label="有效期多少天"  name="validDay" dataType="number"   :value="formItem.validDay" />
      <f-form-item label=""  name="isHaveValidDay" dataType="number"   :value="formItem.isHaveValidDay" />
      <f-form-item label="是否上架（2不上架，1上架）"  name="isShelf" dataType="number"   :value="formItem.isShelf" />
      <f-form-item label="是否上架到代理商"  name="isShelfAgent" dataType="number"   :value="formItem.isShelfAgent" />
      <f-form-item label="首页是否推荐"  name="isHomeRecommend" dataType="number"   :value="formItem.isHomeRecommend" />
      <f-form-item label="商城是否推荐"  name="isMallRecommend" dataType="number"   :value="formItem.isMallRecommend" />
      <f-form-item label="是否在商城展示"  name="isShowShop" dataType="number"   :value="formItem.isShowShop" />
      <f-form-item label="是否限制数量"  name="isLimitNumber" dataType="number"   :value="formItem.isLimitNumber" />
      <f-form-item label="排序"  name="goodsSort" dataType="number"   :value="formItem.goodsSort" />
      <f-form-item label="扫码文字说明"  name="useDesc" dataType="${formField.dataType}"   :value="formItem.useDesc" />
      <f-form-item label="是否删除"  name="deleted" dataType="number"   :value="formItem.deleted" />
      <f-form-item label="更新人"  name="updateUser" dataType="${formField.dataType}"   :value="formItem.updateUser" />
      <f-form-item label="更新时间"  name="updateTime" dataType="${formField.dataType}"   :value="formItem.updateTime" />
      <f-form-item label="创建人"  name="createUser" dataType="${formField.dataType}"   :value="formItem.createUser" />
      <f-form-item label="创建时间"  name="createTime" dataType="${formField.dataType}"   :value="formItem.createTime" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'goodsForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          goodsId: '',
          goodsName: '',
          goodsPrice: '',
          vipPrice: '',
          agentPrice: '',
          goodsImg: '',
          detailsImg: '',
          categoryId: '',
          isIntegral: '',
          integralValue: '',
          goodsDesc: '',
          inventory: '',
          sales: '',
          realSales: '',
          coverImg: '',
          validDay: '',
          isHaveValidDay: '',
          isShelf: '',
          isShelfAgent: '',
          isHomeRecommend: '',
          isMallRecommend: '',
          isShowShop: '',
          isLimitNumber: '',
          goodsSort: '',
          useDesc: '',
          deleted: '',
          updateUser: '',
          updateTime: '',
          createUser: '',
          createTime: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.goodsId) {
          let params={
              goodsId:data.goodsId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
